# words/admin.py

from django.contrib import admin
from .models import Noun, Verb, Adjective, Other, VerbConjugation, Synset, Term

class VerbConjugationInline(admin.TabularInline):
    model = VerbConjugation
    extra = 0
    readonly_fields = ('form_type', 'person', 'conjugated_form')
    can_delete = False
    show_change_link = True

@admin.register(Noun)
class NounAdmin(admin.ModelAdmin):
    list_display = ('word', 'chinese', 'level', 'gender', 'plurals')
    search_fields = ('word', 'chinese')
    list_filter = ('level', 'gender')
    ordering = ('word',)

@admin.register(Verb)
class VerbAdmin(admin.ModelAdmin):
    list_display = ('word', 'chinese', 'level', 'stark', 'divisible', 'reflexive', 'auxiliary')
    search_fields = ('word', 'chinese')
    list_filter = ('level', 'stark', 'divisible', 'reflexive', 'auxiliary')
    ordering = ('word',)
    inlines = [VerbConjugationInline]

@admin.register(Adjective)
class AdjectiveAdmin(admin.ModelAdmin):
    list_display = ('word', 'chinese', 'level')
    search_fields = ('word', 'chinese')
    list_filter = ('level',)
    ordering = ('word',)

@admin.register(Other)
class OtherAdmin(admin.ModelAdmin):
    list_display = ('word', 'chinese', 'level')
    search_fields = ('word', 'chinese')
    list_filter = ('level',)
    ordering = ('word',)

@admin.register(VerbConjugation)
class VerbConjugationAdmin(admin.ModelAdmin):
    list_display = ('verb', 'form_type', 'person', 'conjugated_form')
    search_fields = ('verb__word', 'conjugated_form')
    list_filter = ('form_type', 'person')
    ordering = ('verb', 'form_type', 'person')
